package com.basic.library.utils;

import android.content.SharedPreferences.Editor;

import com.jeremy.fastsharedpreferences.FastSharedPreferences;


public class PreferencesUtils {
    private static String FSP_ID = "PreferencesUtils";

    public static void setStringPreferences(String preference, String key,
                                            String value) {
        FastSharedPreferences sharedPreferences = FastSharedPreferences.get(FSP_ID);
        Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.apply();
    }

    public static String getStringPreferences(String preference, String key,
                                              String defaultValue) {
        FastSharedPreferences sharedPreferences = FastSharedPreferences.get(FSP_ID);
        return sharedPreferences.getString(key, defaultValue);
    }

    public static void setBooleanPreferences(String preference, String key,
                                             boolean value) {
        FastSharedPreferences sharedPreferences = FastSharedPreferences.get(FSP_ID);
        Editor editor = sharedPreferences.edit();
        editor.putBoolean(key, value);
        editor.commit();
    }

    public static boolean getBooleanPreferences(String preference, String key,
                                                boolean defaultValue) {
        FastSharedPreferences sharedPreferences = FastSharedPreferences.get(FSP_ID);
        return sharedPreferences.getBoolean(key, defaultValue);
    }
}
